home *** CD-ROM | disk | FTP | other *** search
- //************************************************************************
- // Verify handling of mandatory AppleEvents
-
- #include "mymenv.h"
- #include "myAEvents.h"
-
- void main(void)
- {
- Initialize_MAC();
-
- class Open_appl : AppleEventOpenAppl
- {
- OSErr operator() (void) { alert("Got OpenAppl Event"); return noErr; }
- };
- Open_appl open_appl;
-
- class Open_doc
- {
- public:
- Open_doc(const int no_items) { alert("%d items to open",no_items); }
- Boolean operator () (AliasHandle file_spec)
- { alert("document to open '%s'",get_full_path(file_spec));
- return TRUE; }
- };
- AppleEventOpenDoc<Open_doc> open_doc;
-
- QuitFlag quit_flag;
-
- const long event_timeout = 20;
- EventRecord theEvent;
-
- notify("Entering the event loop... Press any key or send a Quit event to stop");
-
- while( !quit_flag.quitting() )
- {
- if( !WaitNextEvent(everyEvent, &theEvent, event_timeout, nil) )
- continue; // got null event, do nothing
-
- switch( theEvent.what )
- {
- case kHighLevelEvent: // All High-level events we're going to receive
- do_well( AEProcessAppleEvent(&theEvent) ); // are Apple events
- continue;
-
- case keyDown:
- case autoKey:
- break; // Any key quits
-
- default:
- continue;
- }
- break;
- }
-
- if( quit_flag.quitting() )
- alert("Must've got quit event");
-
- }